﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SuntabuAssistant.AssistAchieve.Action
{
    public class CaptureScreen
    {

        public static void GetImage(int width,int height)//打印屏幕       
        {
            try
            {
                var tempImagePath = Application.StartupPath;
                string temp = tempImagePath + "\\CurrentScreenImage"; 
                Directory.CreateDirectory(@temp);
                Image i = new Bitmap(width, height); 
                var g = Graphics.FromImage(i);
                g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(width, height));
                i.Save(@temp + "\\" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".jpg"); g.Dispose();
                MessageBox.Show("截图成功！");
            }
            catch
            {
                MessageBox.Show("截图失败！");
            }
        }


    }
}
